<?php
namespace Tbf\Bundle\DatabaseBundle\Command;
use Doctrine\DBAL\LockMode;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Tbf\Bundle\TbfBundle\Command\TbfCommand;
use Tbf\Bundle\TbfBundle\Exception\BusinessException;

/**
 * orm某数据库表重建(可以重建tree closure)
 */
class OrmRebuildCommand extends TbfCommand
{
    protected function configure()
    {
        $this
            ->setName('tbf:database:orm:rebuild')
            ->setDescription('rebuild a tree closure table base on origin table')
            ->addArgument('entity', InputArgument::REQUIRED, 'origin table class name');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $entity = $input->getArgument('entity');
        $entity = str_replace('/','\\',$entity);
        $this->getContainer()->get('tbf_database')->ormRebuildTable($entity);
    }
}
